package com.zqq.message.presenter

import com.zqq.baselibrary.ext.excute
import com.zqq.baselibrary.http.rx.BaseSubscriber
import com.zqq.baselibrary.presenter.BasePresenter
import com.zqq.message.presenter.view.MessageView
import com.zqq.message.service.MessageService
import com.zqq.message.service.bean.Message
import javax.inject.Inject

/**
 * 消息列表 Presenter
 * wc
 * @author zqq on 2018/8/6
 */
class MessagePresenter @Inject constructor() : BasePresenter<MessageView>() {

    @Inject
    lateinit var messageService: MessageService

    /**
     * 获取消息列表
     */
    fun getMessageList() {
        if (!checkNetWork()) {
            return
        }
        mView.showLoading()
        messageService.getMessageList()
                .excute(object : BaseSubscriber<MutableList<Message>?>(mView) {
                    override fun onNext(t: MutableList<Message>?) {
                        mView.onGetMessageResult(t)
                    }
                }, lifecycleProvider)

    }

}